Build in models

PCA

Code
from BI import bi, jnp

m=bi()
m.data('iris.csv', sep=',') # Data is already scaled
m.data_on_model = dict(
    X=jnp.array(m.df.iloc[:,0:-2].values)
)
m.fit(m.models.pca(type="classic"), progress_bar=False) # or robust, sparse, classic, sparse_robust_ard

m.models.pca.plot(
    X=m.df.iloc[:,0:-2].values,
    y=m.df.iloc[:,-2].values, 
    feature_names=m.df.columns[0:-2], 
    target_names=m.df.iloc[:,-1].unique(),
    color_var=m.df.iloc[:,0].values,
    shape_var=m.df.iloc[:,-2].values
)
jax.local_device_count 16

Survival analysis

Code
from BI import bi, jnp

m = bi()
m.data('mastectomy.csv', sep=',').head()
m.df.metastasized = (m.df.metastasized.values == "yes").astype(jnp.int64)

# Import time-steps and events
m.models.survival.import_time_even(
    m.df.time.values, 
    m.df.event.values, interval_length=3
)

# To import time-fixed covariates
m.models.survival.import_covF(
    m.df.metastasized.values, ['metastasized']
) 

# To import time-varying covariates ⚠️ Experimental feature
# m.models.survival.import_covV 

m.fit(m.models.survival.model, num_samples=500) 

m.summary()

m.models.survival.plot_surv( beta = 'Hazard_rate_metastasized')
jax.local_device_count 16
------------------------------------------------------------------------------
Survival concern 44 individuals in 76 intervals.
18.0 individuals experienced the event.
------------------------------------------------------------------------------
Covariates imported: ['metastasized']
Surv object now has 1 covariates: ['metastasized']
⚠️This function is still in development. Use it with caution. ⚠️
⚠️This function is still in development. Use it with caution. ⚠️
  0%|          | 0/1000 [00:00<?, ?it/s]
⚠️This function is still in development. Use it with caution. ⚠️
warmup:   0%|          | 1/1000 [00:01<20:58,  1.26s/it, 1 steps of size 2.34e+00. acc. prob=0.00]warmup:   2%|▏         | 18/1000 [00:01<00:55, 17.70it/s, 1023 steps of size 2.28e-01. acc. prob=0.73]warmup:   3%|▎         | 27/1000 [00:01<00:45, 21.36it/s, 1023 steps of size 3.79e-01. acc. prob=0.76]warmup:   3%|▎         | 33/1000 [00:01<00:39, 24.45it/s, 1023 steps of size 1.43e-01. acc. prob=0.75]warmup:   4%|▍         | 39/1000 [00:02<00:39, 24.64it/s, 1023 steps of size 2.71e-01. acc. prob=0.76]warmup:   4%|▍         | 44/1000 [00:02<00:37, 25.42it/s, 1023 steps of size 2.70e-01. acc. prob=0.77]warmup:   5%|▍         | 48/1000 [00:02<00:36, 26.13it/s, 1023 steps of size 3.67e-01. acc. prob=0.77]warmup:   5%|▌         | 52/1000 [00:02<00:35, 26.89it/s, 1023 steps of size 3.01e-01. acc. prob=0.77]warmup:   6%|▌         | 56/1000 [00:02<00:34, 27.61it/s, 1023 steps of size 2.82e-01. acc. prob=0.77]warmup:   6%|▌         | 60/1000 [00:02<00:34, 27.59it/s, 1023 steps of size 1.20e-01. acc. prob=0.77]warmup:   6%|▋         | 64/1000 [00:02<00:35, 26.15it/s, 1023 steps of size 2.20e-01. acc. prob=0.77]warmup:   7%|▋         | 68/1000 [00:03<00:34, 26.97it/s, 1023 steps of size 1.15e-01. acc. prob=0.77]warmup:   7%|▋         | 71/1000 [00:03<00:34, 27.06it/s, 511 steps of size 1.62e-01. acc. prob=0.77] warmup:   7%|▋         | 74/1000 [00:03<00:35, 25.86it/s, 1023 steps of size 1.90e-01. acc. prob=0.77]warmup:   8%|▊         | 78/1000 [00:03<00:32, 28.47it/s, 1023 steps of size 1.96e-01. acc. prob=0.77]warmup:   8%|▊         | 81/1000 [00:03<00:34, 26.86it/s, 1023 steps of size 2.20e-01. acc. prob=0.78]warmup:   8%|▊         | 84/1000 [00:03<00:35, 25.74it/s, 1023 steps of size 3.05e-01. acc. prob=0.78]warmup:   9%|▉         | 88/1000 [00:03<00:34, 26.80it/s, 1023 steps of size 3.36e-01. acc. prob=0.78]warmup:   9%|▉         | 91/1000 [00:03<00:33, 26.95it/s, 1023 steps of size 3.18e-01. acc. prob=0.78]warmup:  10%|▉         | 95/1000 [00:04<00:31, 28.88it/s, 1023 steps of size 2.14e-01. acc. prob=0.78]warmup:  10%|▉         | 99/1000 [00:04<00:30, 29.40it/s, 1023 steps of size 2.19e-01. acc. prob=0.78]warmup:  10%|█         | 105/1000 [00:04<00:24, 36.06it/s, 1023 steps of size 8.07e-03. acc. prob=0.76]warmup:  11%|█         | 109/1000 [00:04<00:27, 32.47it/s, 1023 steps of size 1.22e-02. acc. prob=0.77]warmup:  11%|█▏        | 113/1000 [00:04<00:27, 32.33it/s, 1023 steps of size 8.33e-03. acc. prob=0.77]warmup:  12%|█▏        | 118/1000 [00:04<00:25, 35.07it/s, 1023 steps of size 8.59e-03. acc. prob=0.77]warmup:  12%|█▏        | 122/1000 [00:04<00:25, 34.59it/s, 1023 steps of size 9.81e-03. acc. prob=0.77]warmup:  13%|█▎        | 126/1000 [00:05<00:27, 31.67it/s, 1023 steps of size 1.26e-02. acc. prob=0.77]warmup:  13%|█▎        | 130/1000 [00:05<00:27, 32.15it/s, 198 steps of size 5.00e-03. acc. prob=0.77] warmup:  13%|█▎        | 134/1000 [00:05<00:29, 28.90it/s, 1023 steps of size 1.72e-02. acc. prob=0.77]warmup:  14%|█▍        | 139/1000 [00:05<00:27, 31.52it/s, 1023 steps of size 4.45e-03. acc. prob=0.77]warmup:  14%|█▍        | 143/1000 [00:05<00:27, 31.05it/s, 511 steps of size 1.49e-02. acc. prob=0.77] warmup:  15%|█▍        | 148/1000 [00:05<00:25, 33.87it/s, 511 steps of size 1.32e-02. acc. prob=0.77]warmup:  16%|█▌        | 155/1000 [00:05<00:21, 39.46it/s, 1023 steps of size 3.88e-03. acc. prob=0.77]warmup:  16%|█▌        | 159/1000 [00:05<00:22, 36.82it/s, 511 steps of size 8.84e-03. acc. prob=0.77] warmup:  16%|█▋        | 163/1000 [00:06<00:22, 37.34it/s, 277 steps of size 3.32e-03. acc. prob=0.77]warmup:  17%|█▋        | 167/1000 [00:06<00:23, 35.40it/s, 1023 steps of size 3.52e-03. acc. prob=0.77]warmup:  17%|█▋        | 171/1000 [00:06<00:23, 34.79it/s, 493 steps of size 2.51e-03. acc. prob=0.77] warmup:  18%|█▊        | 175/1000 [00:06<00:23, 34.95it/s, 255 steps of size 5.26e-03. acc. prob=0.77]warmup:  18%|█▊        | 179/1000 [00:06<00:24, 33.50it/s, 1023 steps of size 1.08e-02. acc. prob=0.77]warmup:  18%|█▊        | 183/1000 [00:06<00:26, 30.77it/s, 1023 steps of size 6.28e-03. acc. prob=0.77]warmup:  19%|█▉        | 188/1000 [00:06<00:24, 32.55it/s, 1023 steps of size 7.36e-03. acc. prob=0.77]warmup:  19%|█▉        | 193/1000 [00:06<00:22, 36.60it/s, 244 steps of size 9.82e-03. acc. prob=0.77] warmup:  20%|█▉        | 198/1000 [00:07<00:20, 38.46it/s, 1023 steps of size 4.88e-03. acc. prob=0.77]warmup:  20%|██        | 202/1000 [00:07<00:20, 38.09it/s, 393 steps of size 3.74e-03. acc. prob=0.77] warmup:  21%|██        | 206/1000 [00:07<00:20, 38.49it/s, 272 steps of size 4.18e-03. acc. prob=0.77]warmup:  21%|██        | 210/1000 [00:07<00:20, 38.89it/s, 511 steps of size 1.10e-02. acc. prob=0.77]warmup:  21%|██▏       | 214/1000 [00:07<00:20, 38.33it/s, 417 steps of size 9.88e-03. acc. prob=0.77]warmup:  22%|██▏       | 219/1000 [00:07<00:19, 39.25it/s, 511 steps of size 8.36e-03. acc. prob=0.77]warmup:  22%|██▏       | 224/1000 [00:07<00:19, 39.75it/s, 1023 steps of size 8.50e-03. acc. prob=0.78]warmup:  23%|██▎       | 228/1000 [00:07<00:20, 38.00it/s, 366 steps of size 4.27e-03. acc. prob=0.77] warmup:  23%|██▎       | 232/1000 [00:07<00:21, 34.92it/s, 511 steps of size 1.19e-02. acc. prob=0.78]warmup:  24%|██▍       | 238/1000 [00:08<00:19, 38.11it/s, 1023 steps of size 8.16e-03. acc. prob=0.78]warmup:  24%|██▍       | 242/1000 [00:08<00:22, 33.84it/s, 1023 steps of size 7.33e-03. acc. prob=0.78]warmup:  25%|██▍       | 246/1000 [00:08<00:21, 34.87it/s, 511 steps of size 1.01e-02. acc. prob=0.78] warmup:  25%|██▌       | 250/1000 [00:08<00:20, 36.03it/s, 1023 steps of size 7.59e-03. acc. prob=0.78]warmup:  26%|██▌       | 255/1000 [00:08<00:19, 38.73it/s, 1023 steps of size 9.87e-03. acc. prob=0.77]warmup:  26%|██▌       | 260/1000 [00:08<00:18, 38.99it/s, 1023 steps of size 7.98e-03. acc. prob=0.77]warmup:  26%|██▋       | 264/1000 [00:08<00:19, 38.01it/s, 1023 steps of size 8.28e-03. acc. prob=0.78]warmup:  27%|██▋       | 269/1000 [00:08<00:18, 38.96it/s, 511 steps of size 7.14e-03. acc. prob=0.78] warmup:  27%|██▋       | 273/1000 [00:09<00:19, 36.73it/s, 1023 steps of size 1.09e-02. acc. prob=0.78]warmup:  28%|██▊       | 277/1000 [00:09<00:19, 37.53it/s, 511 steps of size 8.85e-03. acc. prob=0.78] warmup:  28%|██▊       | 281/1000 [00:09<00:21, 33.55it/s, 1023 steps of size 1.18e-02. acc. prob=0.78]warmup:  29%|██▊       | 287/1000 [00:09<00:19, 36.43it/s, 1023 steps of size 5.72e-03. acc. prob=0.78]warmup:  29%|██▉       | 291/1000 [00:09<00:21, 33.11it/s, 511 steps of size 1.01e-02. acc. prob=0.78] warmup:  30%|██▉       | 297/1000 [00:09<00:18, 38.26it/s, 511 steps of size 8.21e-03. acc. prob=0.78]warmup:  30%|███       | 301/1000 [00:09<00:18, 38.54it/s, 1023 steps of size 5.30e-03. acc. prob=0.78]warmup:  31%|███       | 306/1000 [00:09<00:18, 38.29it/s, 1023 steps of size 5.11e-03. acc. prob=0.78]warmup:  31%|███       | 310/1000 [00:10<00:18, 37.12it/s, 1023 steps of size 6.71e-03. acc. prob=0.78]warmup:  32%|███▏      | 315/1000 [00:10<00:17, 38.41it/s, 1023 steps of size 7.64e-03. acc. prob=0.78]warmup:  32%|███▏      | 320/1000 [00:10<00:17, 39.02it/s, 1023 steps of size 7.06e-03. acc. prob=0.78]warmup:  32%|███▎      | 325/1000 [00:10<00:17, 37.66it/s, 1023 steps of size 3.26e-03. acc. prob=0.78]warmup:  33%|███▎      | 330/1000 [00:10<00:18, 37.07it/s, 1023 steps of size 6.10e-03. acc. prob=0.78]warmup:  34%|███▎      | 335/1000 [00:10<00:16, 40.20it/s, 511 steps of size 3.42e-03. acc. prob=0.78] warmup:  34%|███▍      | 340/1000 [00:10<00:17, 38.40it/s, 1023 steps of size 4.34e-03. acc. prob=0.78]warmup:  34%|███▍      | 344/1000 [00:10<00:17, 36.95it/s, 1023 steps of size 4.37e-03. acc. prob=0.78]warmup:  35%|███▍      | 348/1000 [00:11<00:17, 36.47it/s, 511 steps of size 2.93e-03. acc. prob=0.78] warmup:  35%|███▌      | 352/1000 [00:11<00:19, 33.78it/s, 255 steps of size 1.03e-02. acc. prob=0.78]warmup:  36%|███▌      | 356/1000 [00:11<00:19, 33.33it/s, 511 steps of size 9.23e-03. acc. prob=0.78]warmup:  36%|███▌      | 362/1000 [00:11<00:16, 38.00it/s, 511 steps of size 4.78e-03. acc. prob=0.78]warmup:  37%|███▋      | 366/1000 [00:11<00:16, 37.51it/s, 511 steps of size 6.39e-03. acc. prob=0.78]warmup:  37%|███▋      | 372/1000 [00:11<00:15, 39.82it/s, 1023 steps of size 5.92e-03. acc. prob=0.78]warmup:  38%|███▊      | 377/1000 [00:11<00:15, 40.53it/s, 511 steps of size 8.73e-03. acc. prob=0.78] warmup:  38%|███▊      | 382/1000 [00:11<00:14, 42.63it/s, 511 steps of size 6.23e-03. acc. prob=0.78]warmup:  39%|███▉      | 388/1000 [00:12<00:14, 42.70it/s, 1023 steps of size 6.38e-03. acc. prob=0.78]warmup:  39%|███▉      | 394/1000 [00:12<00:14, 43.19it/s, 1023 steps of size 4.32e-03. acc. prob=0.78]warmup:  40%|███▉      | 399/1000 [00:12<00:14, 40.57it/s, 1023 steps of size 5.20e-03. acc. prob=0.78]warmup:  40%|████      | 404/1000 [00:12<00:14, 41.55it/s, 364 steps of size 3.96e-03. acc. prob=0.78] warmup:  41%|████      | 409/1000 [00:12<00:15, 37.08it/s, 1023 steps of size 7.17e-03. acc. prob=0.78]warmup:  42%|████▏     | 415/1000 [00:12<00:14, 41.30it/s, 511 steps of size 8.35e-03. acc. prob=0.78] warmup:  42%|████▏     | 420/1000 [00:12<00:14, 41.06it/s, 511 steps of size 1.11e-02. acc. prob=0.78]warmup:  42%|████▎     | 425/1000 [00:12<00:14, 40.33it/s, 511 steps of size 8.61e-03. acc. prob=0.78]warmup:  43%|████▎     | 430/1000 [00:13<00:14, 39.29it/s, 511 steps of size 5.16e-03. acc. prob=0.78]warmup:  44%|████▎     | 435/1000 [00:13<00:13, 40.59it/s, 511 steps of size 5.72e-03. acc. prob=0.78]warmup:  44%|████▍     | 440/1000 [00:13<00:14, 38.65it/s, 343 steps of size 8.21e-03. acc. prob=0.78]warmup:  44%|████▍     | 444/1000 [00:13<00:14, 38.09it/s, 1023 steps of size 6.84e-03. acc. prob=0.78]warmup:  45%|████▍     | 448/1000 [00:13<00:14, 38.36it/s, 1023 steps of size 6.16e-03. acc. prob=0.78]warmup:  45%|████▌     | 452/1000 [00:13<00:14, 37.94it/s, 2 steps of size 1.22e-02. acc. prob=0.78]   warmup:  46%|████▌     | 456/1000 [00:13<00:14, 38.21it/s, 511 steps of size 9.88e-03. acc. prob=0.78]warmup:  46%|████▌     | 461/1000 [00:13<00:13, 41.15it/s, 255 steps of size 1.16e-02. acc. prob=0.78]warmup:  47%|████▋     | 467/1000 [00:14<00:12, 43.52it/s, 1023 steps of size 2.74e-03. acc. prob=0.78]warmup:  47%|████▋     | 472/1000 [00:14<00:13, 38.71it/s, 1023 steps of size 6.48e-03. acc. prob=0.78]warmup:  48%|████▊     | 477/1000 [00:14<00:12, 40.38it/s, 255 steps of size 5.46e-03. acc. prob=0.78] warmup:  48%|████▊     | 483/1000 [00:14<00:11, 44.55it/s, 511 steps of size 1.14e-02. acc. prob=0.78]warmup:  49%|████▉     | 489/1000 [00:14<00:10, 47.57it/s, 511 steps of size 3.94e-03. acc. prob=0.78]warmup:  49%|████▉     | 494/1000 [00:14<00:11, 43.38it/s, 511 steps of size 9.55e-03. acc. prob=0.78]sample:  50%|█████     | 501/1000 [00:14<00:10, 48.58it/s, 341 steps of size 7.57e-03. acc. prob=0.31]sample:  51%|█████     | 506/1000 [00:14<00:10, 47.34it/s, 511 steps of size 7.57e-03. acc. prob=0.70]sample:  51%|█████     | 511/1000 [00:15<00:10, 46.64it/s, 511 steps of size 7.57e-03. acc. prob=0.76]sample:  52%|█████▏    | 516/1000 [00:15<00:10, 46.22it/s, 511 steps of size 7.57e-03. acc. prob=0.77]sample:  52%|█████▏    | 522/1000 [00:15<00:10, 47.33it/s, 511 steps of size 7.57e-03. acc. prob=0.78]sample:  53%|█████▎    | 527/1000 [00:15<00:10, 46.75it/s, 511 steps of size 7.57e-03. acc. prob=0.81]sample:  53%|█████▎    | 533/1000 [00:15<00:09, 48.07it/s, 511 steps of size 7.57e-03. acc. prob=0.82]sample:  54%|█████▍    | 538/1000 [00:15<00:09, 47.14it/s, 511 steps of size 7.57e-03. acc. prob=0.84]sample:  54%|█████▍    | 543/1000 [00:15<00:09, 46.70it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  55%|█████▍    | 548/1000 [00:15<00:09, 46.50it/s, 457 steps of size 7.57e-03. acc. prob=0.84]sample:  55%|█████▌    | 553/1000 [00:15<00:09, 46.02it/s, 417 steps of size 7.57e-03. acc. prob=0.84]sample:  56%|█████▌    | 558/1000 [00:16<00:09, 47.07it/s, 300 steps of size 7.57e-03. acc. prob=0.83]sample:  56%|█████▋    | 563/1000 [00:16<00:09, 47.61it/s, 302 steps of size 7.57e-03. acc. prob=0.82]sample:  57%|█████▋    | 569/1000 [00:16<00:08, 48.25it/s, 511 steps of size 7.57e-03. acc. prob=0.82]sample:  57%|█████▋    | 574/1000 [00:16<00:09, 47.27it/s, 511 steps of size 7.57e-03. acc. prob=0.83]sample:  58%|█████▊    | 579/1000 [00:16<00:09, 46.70it/s, 511 steps of size 7.57e-03. acc. prob=0.84]sample:  58%|█████▊    | 584/1000 [00:16<00:08, 46.50it/s, 511 steps of size 7.57e-03. acc. prob=0.84]sample:  59%|█████▉    | 589/1000 [00:16<00:08, 46.66it/s, 395 steps of size 7.57e-03. acc. prob=0.84]sample:  59%|█████▉    | 594/1000 [00:16<00:08, 46.52it/s, 511 steps of size 7.57e-03. acc. prob=0.83]sample:  60%|█████▉    | 599/1000 [00:16<00:08, 45.72it/s, 511 steps of size 7.57e-03. acc. prob=0.84]sample:  60%|██████    | 604/1000 [00:17<00:08, 45.93it/s, 511 steps of size 7.57e-03. acc. prob=0.84]sample:  61%|██████    | 609/1000 [00:17<00:08, 45.72it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  61%|██████▏   | 614/1000 [00:17<00:08, 46.33it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  62%|██████▏   | 620/1000 [00:17<00:07, 48.64it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  62%|██████▎   | 625/1000 [00:17<00:07, 48.66it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  63%|██████▎   | 630/1000 [00:17<00:07, 48.55it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  64%|██████▎   | 635/1000 [00:17<00:07, 48.36it/s, 511 steps of size 7.57e-03. acc. prob=0.86]sample:  64%|██████▍   | 640/1000 [00:17<00:07, 48.41it/s, 511 steps of size 7.57e-03. acc. prob=0.86]sample:  64%|██████▍   | 645/1000 [00:17<00:07, 48.16it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  65%|██████▌   | 650/1000 [00:17<00:07, 48.39it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  66%|██████▌   | 655/1000 [00:18<00:07, 48.35it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  66%|██████▌   | 661/1000 [00:18<00:06, 50.32it/s, 255 steps of size 7.57e-03. acc. prob=0.85]sample:  67%|██████▋   | 667/1000 [00:18<00:06, 50.63it/s, 369 steps of size 7.57e-03. acc. prob=0.84]sample:  67%|██████▋   | 673/1000 [00:18<00:06, 51.42it/s, 511 steps of size 7.57e-03. acc. prob=0.84]sample:  68%|██████▊   | 679/1000 [00:18<00:06, 52.05it/s, 255 steps of size 7.57e-03. acc. prob=0.84]sample:  68%|██████▊   | 685/1000 [00:18<00:06, 52.32it/s, 511 steps of size 7.57e-03. acc. prob=0.84]sample:  69%|██████▉   | 691/1000 [00:18<00:06, 51.29it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  70%|██████▉   | 697/1000 [00:18<00:05, 51.14it/s, 511 steps of size 7.57e-03. acc. prob=0.84]sample:  70%|███████   | 703/1000 [00:18<00:05, 50.73it/s, 480 steps of size 7.57e-03. acc. prob=0.84]sample:  71%|███████   | 709/1000 [00:19<00:05, 50.04it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  72%|███████▏  | 715/1000 [00:19<00:05, 49.81it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  72%|███████▏  | 720/1000 [00:19<00:05, 49.75it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  72%|███████▎  | 725/1000 [00:19<00:05, 49.73it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  73%|███████▎  | 730/1000 [00:19<00:05, 49.41it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  74%|███████▎  | 735/1000 [00:19<00:05, 48.73it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  74%|███████▍  | 740/1000 [00:19<00:05, 48.40it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  74%|███████▍  | 745/1000 [00:19<00:05, 48.31it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  75%|███████▌  | 750/1000 [00:19<00:05, 48.15it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  76%|███████▌  | 756/1000 [00:20<00:04, 49.59it/s, 511 steps of size 7.57e-03. acc. prob=0.86]sample:  76%|███████▌  | 761/1000 [00:20<00:05, 47.73it/s, 255 steps of size 7.57e-03. acc. prob=0.86]sample:  77%|███████▋  | 766/1000 [00:20<00:04, 47.85it/s, 511 steps of size 7.57e-03. acc. prob=0.86]sample:  77%|███████▋  | 771/1000 [00:20<00:04, 46.37it/s, 511 steps of size 7.57e-03. acc. prob=0.86]sample:  78%|███████▊  | 776/1000 [00:20<00:04, 46.82it/s, 437 steps of size 7.57e-03. acc. prob=0.85]sample:  78%|███████▊  | 781/1000 [00:20<00:04, 46.87it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  79%|███████▊  | 786/1000 [00:20<00:04, 47.20it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  79%|███████▉  | 791/1000 [00:20<00:04, 47.37it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  80%|███████▉  | 797/1000 [00:20<00:04, 48.80it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  80%|████████  | 803/1000 [00:21<00:03, 49.71it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  81%|████████  | 808/1000 [00:21<00:03, 49.29it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  81%|████████▏ | 813/1000 [00:21<00:03, 48.83it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  82%|████████▏ | 819/1000 [00:21<00:03, 50.75it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  82%|████████▎ | 825/1000 [00:21<00:03, 50.93it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  83%|████████▎ | 831/1000 [00:21<00:03, 49.96it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  84%|████████▎ | 837/1000 [00:21<00:03, 50.93it/s, 454 steps of size 7.57e-03. acc. prob=0.85]sample:  84%|████████▍ | 843/1000 [00:21<00:03, 51.33it/s, 255 steps of size 7.57e-03. acc. prob=0.85]sample:  85%|████████▍ | 849/1000 [00:21<00:02, 51.76it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  86%|████████▌ | 855/1000 [00:22<00:02, 50.46it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  86%|████████▌ | 861/1000 [00:22<00:02, 49.54it/s, 511 steps of size 7.57e-03. acc. prob=0.85]sample:  87%|████████▋ | 867/1000 [00:22<00:02, 50.04it/s, 511 steps of size 7.57e-03. acc. prob=0.86]sample:  87%|████████▋ | 873/1000 [00:22<00:02, 49.36it/s, 511 steps of size 7.57e-03. acc. prob=0.86]sample:  88%|████████▊ | 878/1000 [00:22<00:02, 48.90it/s, 511 steps of size 7.57e-03. acc. prob=0.86]sample:  88%|████████▊ | 884/1000 [00:22<00:02, 51.17it/s, 255 steps of size 7.57e-03. acc. prob=0.86]sample:  89%|████████▉ | 890/1000 [00:22<00:02, 50.10it/s, 511 steps of size 7.57e-03. acc. prob=0.86]sample:  90%|████████▉ | 896/1000 [00:22<00:02, 51.97it/s, 255 steps of size 7.57e-03. acc. prob=0.86]sample:  90%|█████████ | 902/1000 [00:22<00:01, 51.91it/s, 511 steps of size 7.57e-03. acc. prob=0.86]sample:  91%|█████████ | 908/1000 [00:23<00:01, 48.45it/s, 1023 steps of size 7.57e-03. acc. prob=0.86]sample:  91%|█████████▏| 913/1000 [00:23<00:01, 48.26it/s, 511 steps of size 7.57e-03. acc. prob=0.86] sample:  92%|█████████▏| 918/1000 [00:23<00:01, 48.27it/s, 511 steps of size 7.57e-03. acc. prob=0.86]sample:  92%|█████████▏| 923/1000 [00:23<00:01, 48.62it/s, 511 steps of size 7.57e-03. acc. prob=0.86]sample:  93%|█████████▎| 928/1000 [00:23<00:01, 48.77it/s, 511 steps of size 7.57e-03. acc. prob=0.86]sample:  93%|█████████▎| 933/1000 [00:23<00:01, 46.33it/s, 511 steps of size 7.57e-03. acc. prob=0.86]sample:  94%|█████████▍| 939/1000 [00:23<00:01, 48.49it/s, 511 steps of size 7.57e-03. acc. prob=0.86]sample:  94%|█████████▍| 944/1000 [00:23<00:01, 47.22it/s, 511 steps of size 7.57e-03. acc. prob=0.86]sample:  95%|█████████▌| 950/1000 [00:24<00:01, 49.14it/s, 511 steps of size 7.57e-03. acc. prob=0.86]sample:  96%|█████████▌| 955/1000 [00:24<00:00, 48.93it/s, 511 steps of size 7.57e-03. acc. prob=0.86]sample:  96%|█████████▌| 962/1000 [00:24<00:00, 52.76it/s, 511 steps of size 7.57e-03. acc. prob=0.86]sample:  97%|█████████▋| 968/1000 [00:24<00:00, 51.68it/s, 511 steps of size 7.57e-03. acc. prob=0.86]sample:  97%|█████████▋| 974/1000 [00:24<00:00, 50.96it/s, 511 steps of size 7.57e-03. acc. prob=0.86]sample:  98%|█████████▊| 980/1000 [00:24<00:00, 51.56it/s, 255 steps of size 7.57e-03. acc. prob=0.86]sample:  99%|█████████▊| 986/1000 [00:24<00:00, 48.65it/s, 511 steps of size 7.57e-03. acc. prob=0.86]sample:  99%|█████████▉| 993/1000 [00:24<00:00, 52.11it/s, 511 steps of size 7.57e-03. acc. prob=0.86]sample: 100%|█████████▉| 999/1000 [00:24<00:00, 51.21it/s, 511 steps of size 7.57e-03. acc. prob=0.86]sample: 100%|██████████| 1000/1000 [00:24<00:00, 40.03it/s, 511 steps of size 7.57e-03. acc. prob=0.86]
⚠️This function is still in development. Use it with caution. ⚠️
⚠️This function is still in development. Use it with caution. ⚠️
⚠️This function is still in development. Use it with caution. ⚠️
arviz - WARNING - Shape validation failed: input_shape: (1, 500), minimum_shape: (chains=2, draws=4)
/home/sosa/work/.venv/lib/python3.12/site-packages/arviz/plots/hdiplot.py:166: FutureWarning:

hdi currently interprets 2d data as (draw, shape) but this will change in a future release to (chain, draw) for coherence with other functions

/home/sosa/work/.venv/lib/python3.12/site-packages/arviz/plots/hdiplot.py:166: FutureWarning:

hdi currently interprets 2d data as (draw, shape) but this will change in a future release to (chain, draw) for coherence with other functions

/home/sosa/work/.venv/lib/python3.12/site-packages/arviz/plots/hdiplot.py:166: FutureWarning:

hdi currently interprets 2d data as (draw, shape) but this will change in a future release to (chain, draw) for coherence with other functions

/home/sosa/work/.venv/lib/python3.12/site-packages/arviz/plots/hdiplot.py:166: FutureWarning:

hdi currently interprets 2d data as (draw, shape) but this will change in a future release to (chain, draw) for coherence with other functions

Gaussian Mixture Models

Code
from BI import bi
from sklearn.datasets import make_blobs
m = bi()

# Generate synthetic data
data, true_labels = make_blobs(
    n_samples=500, centers=8, cluster_std=0.8,
    center_box=(-10,10), random_state=101
)

m.data_on_model = {"data": data,"K": 8 }
m.fit(m.models.gmm) # Optimize model parameters through MCMC sampling
m.plot(X=data,sampler=m.sampler)  # ⚠️ Experimental feature
jax.local_device_count 16
  0%|          | 0/1000 [00:00<?, ?it/s]warmup:   0%|          | 1/1000 [00:04<1:11:59,  4.32s/it, 1 steps of size 2.34e+00. acc. prob=0.00]warmup:   3%|▎         | 29/1000 [00:04<01:45,  9.16it/s, 31 steps of size 3.59e-02. acc. prob=0.73]warmup:   5%|▍         | 46/1000 [00:04<00:59, 16.14it/s, 31 steps of size 2.97e-02. acc. prob=0.75]warmup:   8%|▊         | 79/1000 [00:04<00:26, 34.49it/s, 7 steps of size 7.94e-02. acc. prob=0.77] warmup:  10%|█         | 105/1000 [00:04<00:17, 51.60it/s, 31 steps of size 3.26e-01. acc. prob=0.77]warmup:  13%|█▎        | 132/1000 [00:04<00:11, 73.01it/s, 7 steps of size 4.17e-01. acc. prob=0.78] warmup:  16%|█▌        | 159/1000 [00:04<00:08, 97.13it/s, 7 steps of size 2.93e-01. acc. prob=0.78]warmup:  19%|█▊        | 186/1000 [00:05<00:06, 122.66it/s, 15 steps of size 4.28e-01. acc. prob=0.78]warmup:  22%|██▏       | 216/1000 [00:05<00:05, 152.82it/s, 15 steps of size 5.35e-01. acc. prob=0.78]warmup:  24%|██▍       | 244/1000 [00:05<00:04, 178.17it/s, 15 steps of size 3.82e-01. acc. prob=0.78]warmup:  27%|██▋       | 272/1000 [00:05<00:03, 193.00it/s, 7 steps of size 9.71e-01. acc. prob=0.78] warmup:  30%|██▉       | 298/1000 [00:05<00:03, 206.12it/s, 7 steps of size 9.47e-01. acc. prob=0.78]warmup:  32%|███▎      | 325/1000 [00:05<00:03, 221.45it/s, 15 steps of size 5.69e-01. acc. prob=0.78]warmup:  36%|███▌      | 357/1000 [00:05<00:02, 246.71it/s, 7 steps of size 2.49e-01. acc. prob=0.78] warmup:  39%|███▉      | 390/1000 [00:05<00:02, 268.69it/s, 7 steps of size 6.56e-01. acc. prob=0.79]warmup:  42%|████▎     | 425/1000 [00:05<00:01, 290.89it/s, 7 steps of size 7.48e-01. acc. prob=0.79]warmup:  46%|████▌     | 459/1000 [00:05<00:01, 304.07it/s, 15 steps of size 6.23e-01. acc. prob=0.79]warmup:  49%|████▉     | 491/1000 [00:06<00:01, 297.64it/s, 31 steps of size 2.14e-01. acc. prob=0.79]sample:  52%|█████▏    | 522/1000 [00:06<00:01, 288.36it/s, 15 steps of size 4.07e-01. acc. prob=0.87]sample:  55%|█████▌    | 552/1000 [00:06<00:01, 283.29it/s, 7 steps of size 4.07e-01. acc. prob=0.89] sample:  58%|█████▊    | 583/1000 [00:06<00:01, 288.64it/s, 7 steps of size 4.07e-01. acc. prob=0.89]sample:  61%|██████▏   | 613/1000 [00:06<00:01, 272.88it/s, 15 steps of size 4.07e-01. acc. prob=0.90]sample:  64%|██████▍   | 641/1000 [00:06<00:01, 274.34it/s, 15 steps of size 4.07e-01. acc. prob=0.90]sample:  67%|██████▋   | 669/1000 [00:06<00:01, 274.56it/s, 15 steps of size 4.07e-01. acc. prob=0.90]sample:  70%|██████▉   | 697/1000 [00:06<00:01, 273.02it/s, 15 steps of size 4.07e-01. acc. prob=0.90]sample:  72%|███████▎  | 725/1000 [00:06<00:01, 267.55it/s, 15 steps of size 4.07e-01. acc. prob=0.90]sample:  75%|███████▌  | 752/1000 [00:07<00:00, 267.48it/s, 7 steps of size 4.07e-01. acc. prob=0.90] sample:  78%|███████▊  | 779/1000 [00:07<00:00, 266.52it/s, 15 steps of size 4.07e-01. acc. prob=0.90]sample:  81%|████████  | 806/1000 [00:07<00:00, 264.74it/s, 7 steps of size 4.07e-01. acc. prob=0.90] sample:  83%|████████▎ | 834/1000 [00:07<00:00, 265.20it/s, 31 steps of size 4.07e-01. acc. prob=0.90]sample:  86%|████████▋ | 863/1000 [00:07<00:00, 269.96it/s, 15 steps of size 4.07e-01. acc. prob=0.89]sample:  89%|████████▉ | 891/1000 [00:07<00:00, 271.18it/s, 7 steps of size 4.07e-01. acc. prob=0.90] sample:  92%|█████████▏| 919/1000 [00:07<00:00, 273.38it/s, 23 steps of size 4.07e-01. acc. prob=0.89]sample:  95%|█████████▍| 947/1000 [00:07<00:00, 272.58it/s, 15 steps of size 4.07e-01. acc. prob=0.90]sample:  98%|█████████▊| 975/1000 [00:07<00:00, 270.71it/s, 7 steps of size 4.07e-01. acc. prob=0.90] sample: 100%|██████████| 1000/1000 [00:07<00:00, 125.19it/s, 15 steps of size 4.07e-01. acc. prob=0.90]

Dirichlet Process Mixture Models

Python

Code
from BI import bi
from sklearn.datasets import make_blobs
m = bi()

# Generate synthetic data
data, true_labels = make_blobs(
    n_samples=500, centers=8, cluster_std=0.8,
    center_box=(-10,10), random_state=101
)
m.data_on_model = dict(data=data,T=10)
m.fit(m.models.dpmm)
m.plot(data,m.sampler) # ⚠️ Experimental feature
jax.local_device_count 16
  0%|          | 0/1000 [00:00<?, ?it/s]warmup:   0%|          | 1/1000 [00:02<42:59,  2.58s/it, 1 steps of size 2.34e+00. acc. prob=0.00]warmup:   2%|▏         | 15/1000 [00:02<02:14,  7.30it/s, 511 steps of size 9.88e-03. acc. prob=0.65]warmup:   2%|▏         | 19/1000 [00:02<01:49,  8.92it/s, 511 steps of size 5.50e-03. acc. prob=0.67]warmup:   2%|▏         | 23/1000 [00:03<01:41,  9.59it/s, 319 steps of size 2.97e-02. acc. prob=0.71]warmup:   3%|▎         | 27/1000 [00:03<01:21, 11.99it/s, 255 steps of size 1.66e-02. acc. prob=0.72]warmup:   3%|▎         | 31/1000 [00:03<01:06, 14.52it/s, 255 steps of size 1.59e-02. acc. prob=0.72]warmup:   4%|▎         | 37/1000 [00:03<00:55, 17.44it/s, 511 steps of size 2.80e-02. acc. prob=0.74]warmup:   4%|▍         | 40/1000 [00:04<00:56, 16.92it/s, 31 steps of size 3.96e-02. acc. prob=0.75] warmup:   4%|▍         | 45/1000 [00:04<00:44, 21.64it/s, 159 steps of size 8.74e-02. acc. prob=0.76]warmup:   5%|▍         | 49/1000 [00:04<00:48, 19.80it/s, 127 steps of size 5.86e-02. acc. prob=0.76]warmup:   6%|▌         | 55/1000 [00:04<00:38, 24.73it/s, 255 steps of size 3.37e-02. acc. prob=0.75]warmup:   6%|▌         | 60/1000 [00:04<00:32, 28.96it/s, 63 steps of size 3.53e-02. acc. prob=0.76] warmup:   7%|▋         | 67/1000 [00:04<00:26, 35.61it/s, 127 steps of size 5.84e-02. acc. prob=0.76]warmup:   7%|▋         | 74/1000 [00:04<00:22, 41.49it/s, 63 steps of size 4.28e-02. acc. prob=0.76] warmup:   8%|▊         | 79/1000 [00:04<00:23, 39.56it/s, 127 steps of size 4.89e-02. acc. prob=0.77]warmup:   8%|▊         | 85/1000 [00:05<00:20, 44.17it/s, 15 steps of size 4.18e-02. acc. prob=0.77] warmup:   9%|▉         | 93/1000 [00:05<00:17, 51.58it/s, 63 steps of size 1.00e-01. acc. prob=0.77]warmup:  10%|█         | 100/1000 [00:05<00:17, 52.76it/s, 95 steps of size 7.61e-02. acc. prob=0.77]warmup:  11%|█         | 106/1000 [00:05<00:19, 46.70it/s, 127 steps of size 6.15e-02. acc. prob=0.77]warmup:  11%|█         | 111/1000 [00:05<00:20, 43.18it/s, 63 steps of size 1.32e-01. acc. prob=0.77] warmup:  12%|█▏        | 116/1000 [00:05<00:24, 36.30it/s, 63 steps of size 1.35e-01. acc. prob=0.77]warmup:  12%|█▏        | 120/1000 [00:05<00:25, 34.91it/s, 63 steps of size 7.45e-02. acc. prob=0.77]warmup:  12%|█▏        | 124/1000 [00:06<00:25, 35.03it/s, 255 steps of size 3.41e-02. acc. prob=0.77]warmup:  13%|█▎        | 128/1000 [00:06<00:25, 34.00it/s, 31 steps of size 2.62e-02. acc. prob=0.77] warmup:  13%|█▎        | 132/1000 [00:06<00:25, 33.39it/s, 63 steps of size 1.02e-01. acc. prob=0.77]warmup:  14%|█▎        | 137/1000 [00:06<00:24, 35.72it/s, 255 steps of size 3.71e-02. acc. prob=0.77]warmup:  14%|█▍        | 142/1000 [00:06<00:24, 35.12it/s, 255 steps of size 4.23e-02. acc. prob=0.77]warmup:  15%|█▍        | 147/1000 [00:06<00:22, 38.57it/s, 63 steps of size 8.59e-02. acc. prob=0.78] warmup:  15%|█▌        | 154/1000 [00:06<00:18, 45.22it/s, 127 steps of size 5.55e-02. acc. prob=0.77]warmup:  16%|█▌        | 161/1000 [00:06<00:16, 50.37it/s, 63 steps of size 1.56e-01. acc. prob=0.77] warmup:  17%|█▋        | 168/1000 [00:07<00:15, 55.04it/s, 31 steps of size 2.59e-02. acc. prob=0.77]warmup:  17%|█▋        | 174/1000 [00:07<00:20, 40.71it/s, 127 steps of size 7.51e-02. acc. prob=0.77]warmup:  18%|█▊        | 180/1000 [00:07<00:18, 44.95it/s, 63 steps of size 1.57e-01. acc. prob=0.78] warmup:  19%|█▉        | 188/1000 [00:07<00:15, 52.09it/s, 63 steps of size 1.08e-01. acc. prob=0.78]warmup:  20%|█▉        | 198/1000 [00:07<00:12, 62.70it/s, 31 steps of size 1.99e-01. acc. prob=0.78]warmup:  21%|██        | 210/1000 [00:07<00:10, 75.95it/s, 31 steps of size 1.63e-01. acc. prob=0.78]warmup:  22%|██▏       | 219/1000 [00:07<00:09, 79.68it/s, 15 steps of size 1.09e-01. acc. prob=0.78]warmup:  23%|██▎       | 229/1000 [00:07<00:09, 84.83it/s, 63 steps of size 8.33e-02. acc. prob=0.78]warmup:  24%|██▍       | 238/1000 [00:08<00:09, 83.31it/s, 31 steps of size 1.42e-01. acc. prob=0.78]warmup:  25%|██▍       | 247/1000 [00:08<00:08, 85.03it/s, 31 steps of size 1.92e-01. acc. prob=0.78]warmup:  26%|██▌       | 256/1000 [00:08<00:08, 85.46it/s, 31 steps of size 1.82e-02. acc. prob=0.78]warmup:  26%|██▋       | 265/1000 [00:08<00:16, 44.02it/s, 63 steps of size 1.82e-01. acc. prob=0.78]warmup:  27%|██▋       | 272/1000 [00:09<00:23, 31.10it/s, 63 steps of size 1.29e-01. acc. prob=0.78]warmup:  28%|██▊       | 278/1000 [00:09<00:22, 32.63it/s, 31 steps of size 1.06e-01. acc. prob=0.78]warmup:  28%|██▊       | 283/1000 [00:09<00:21, 33.11it/s, 31 steps of size 1.78e-01. acc. prob=0.78]warmup:  29%|██▉       | 288/1000 [00:09<00:21, 32.83it/s, 63 steps of size 1.34e-02. acc. prob=0.78]warmup:  29%|██▉       | 293/1000 [00:09<00:24, 29.02it/s, 31 steps of size 1.70e-01. acc. prob=0.78]warmup:  30%|███       | 300/1000 [00:09<00:19, 35.61it/s, 31 steps of size 9.51e-02. acc. prob=0.78]warmup:  30%|███       | 305/1000 [00:10<00:19, 34.95it/s, 127 steps of size 3.13e-02. acc. prob=0.78]warmup:  31%|███       | 310/1000 [00:10<00:27, 24.76it/s, 255 steps of size 2.30e-02. acc. prob=0.78]warmup:  31%|███▏      | 314/1000 [00:10<00:27, 25.04it/s, 63 steps of size 1.04e-01. acc. prob=0.78] warmup:  32%|███▏      | 324/1000 [00:10<00:18, 37.55it/s, 31 steps of size 1.46e-01. acc. prob=0.78]warmup:  33%|███▎      | 331/1000 [00:10<00:15, 42.90it/s, 31 steps of size 4.24e-02. acc. prob=0.78]warmup:  34%|███▎      | 337/1000 [00:10<00:14, 44.43it/s, 63 steps of size 6.09e-02. acc. prob=0.78]warmup:  34%|███▍      | 343/1000 [00:11<00:16, 39.50it/s, 127 steps of size 4.55e-02. acc. prob=0.78]warmup:  35%|███▌      | 350/1000 [00:11<00:15, 42.69it/s, 127 steps of size 4.96e-02. acc. prob=0.78]warmup:  36%|███▌      | 355/1000 [00:11<00:15, 42.34it/s, 63 steps of size 4.70e-02. acc. prob=0.78] warmup:  36%|███▌      | 361/1000 [00:11<00:13, 45.80it/s, 63 steps of size 1.12e-01. acc. prob=0.78]warmup:  37%|███▋      | 368/1000 [00:11<00:12, 51.70it/s, 31 steps of size 3.62e-02. acc. prob=0.78]warmup:  37%|███▋      | 374/1000 [00:11<00:13, 46.85it/s, 31 steps of size 5.59e-02. acc. prob=0.78]warmup:  38%|███▊      | 380/1000 [00:11<00:14, 44.19it/s, 63 steps of size 1.07e-01. acc. prob=0.78]warmup:  39%|███▊      | 386/1000 [00:11<00:12, 47.69it/s, 63 steps of size 6.86e-02. acc. prob=0.78]warmup:  39%|███▉      | 392/1000 [00:12<00:13, 45.50it/s, 63 steps of size 8.69e-02. acc. prob=0.78]warmup:  40%|███▉      | 397/1000 [00:12<00:13, 43.12it/s, 127 steps of size 3.79e-02. acc. prob=0.78]warmup:  40%|████      | 402/1000 [00:12<00:15, 39.13it/s, 63 steps of size 6.12e-02. acc. prob=0.78] warmup:  41%|████      | 407/1000 [00:12<00:17, 32.97it/s, 255 steps of size 2.23e-02. acc. prob=0.78]warmup:  41%|████      | 411/1000 [00:12<00:22, 25.93it/s, 127 steps of size 5.93e-02. acc. prob=0.78]warmup:  42%|████▏     | 417/1000 [00:12<00:18, 31.79it/s, 31 steps of size 5.71e-02. acc. prob=0.78] warmup:  42%|████▏     | 424/1000 [00:13<00:14, 38.86it/s, 31 steps of size 9.55e-02. acc. prob=0.78]warmup:  43%|████▎     | 432/1000 [00:13<00:11, 47.74it/s, 31 steps of size 4.30e-02. acc. prob=0.78]warmup:  44%|████▍     | 438/1000 [00:13<00:12, 46.18it/s, 63 steps of size 6.16e-02. acc. prob=0.78]warmup:  44%|████▍     | 444/1000 [00:13<00:12, 45.80it/s, 63 steps of size 8.61e-02. acc. prob=0.79]warmup:  45%|████▍     | 449/1000 [00:13<00:13, 41.04it/s, 127 steps of size 2.98e-02. acc. prob=0.78]warmup:  45%|████▌     | 454/1000 [00:13<00:16, 32.53it/s, 255 steps of size 1.38e-02. acc. prob=0.78]warmup:  46%|████▌     | 458/1000 [00:15<00:58,  9.27it/s, 63 steps of size 5.24e-02. acc. prob=0.78] warmup:  46%|████▌     | 461/1000 [00:15<00:50, 10.73it/s, 31 steps of size 7.84e-02. acc. prob=0.78]warmup:  46%|████▋     | 465/1000 [00:15<00:47, 11.30it/s, 255 steps of size 2.61e-02. acc. prob=0.78]warmup:  47%|████▋     | 468/1000 [00:16<00:49, 10.83it/s, 63 steps of size 9.44e-02. acc. prob=0.78] warmup:  47%|████▋     | 471/1000 [00:16<00:46, 11.34it/s, 255 steps of size 2.90e-02. acc. prob=0.78]warmup:  47%|████▋     | 473/1000 [00:16<00:44, 11.79it/s, 63 steps of size 9.14e-02. acc. prob=0.78] warmup:  48%|████▊     | 476/1000 [00:16<00:46, 11.38it/s, 255 steps of size 2.98e-02. acc. prob=0.78]warmup:  48%|████▊     | 478/1000 [00:16<00:44, 11.84it/s, 63 steps of size 5.97e-03. acc. prob=0.78] warmup:  48%|████▊     | 480/1000 [00:17<01:01,  8.51it/s, 511 steps of size 1.74e-02. acc. prob=0.78]warmup:  48%|████▊     | 482/1000 [00:17<00:55,  9.39it/s, 127 steps of size 4.40e-02. acc. prob=0.78]warmup:  49%|████▊     | 486/1000 [00:17<00:38, 13.49it/s, 31 steps of size 3.30e-02. acc. prob=0.78] warmup:  49%|████▉     | 488/1000 [00:17<00:35, 14.49it/s, 63 steps of size 8.34e-02. acc. prob=0.78]warmup:  49%|████▉     | 493/1000 [00:17<00:23, 21.24it/s, 31 steps of size 2.90e-02. acc. prob=0.78]warmup:  50%|████▉     | 497/1000 [00:17<00:23, 21.52it/s, 255 steps of size 2.77e-02. acc. prob=0.78]warmup:  50%|█████     | 500/1000 [00:18<00:21, 23.04it/s, 63 steps of size 4.79e-02. acc. prob=0.78] sample:  50%|█████     | 504/1000 [00:18<00:18, 26.82it/s, 63 steps of size 4.79e-02. acc. prob=0.96]sample:  51%|█████     | 508/1000 [00:18<00:17, 27.86it/s, 127 steps of size 4.79e-02. acc. prob=0.96]sample:  51%|█████     | 512/1000 [00:18<00:16, 30.05it/s, 63 steps of size 4.79e-02. acc. prob=0.96] sample:  52%|█████▏    | 516/1000 [00:18<00:15, 31.41it/s, 63 steps of size 4.79e-02. acc. prob=0.96]sample:  52%|█████▏    | 521/1000 [00:18<00:13, 35.32it/s, 63 steps of size 4.79e-02. acc. prob=0.96]sample:  52%|█████▎    | 525/1000 [00:18<00:14, 32.77it/s, 63 steps of size 4.79e-02. acc. prob=0.96]sample:  53%|█████▎    | 529/1000 [00:18<00:14, 31.55it/s, 63 steps of size 4.79e-02. acc. prob=0.97]sample:  53%|█████▎    | 533/1000 [00:18<00:14, 32.22it/s, 63 steps of size 4.79e-02. acc. prob=0.96]sample:  54%|█████▎    | 537/1000 [00:19<00:16, 28.17it/s, 127 steps of size 4.79e-02. acc. prob=0.95]sample:  54%|█████▍    | 541/1000 [00:19<00:15, 29.83it/s, 63 steps of size 4.79e-02. acc. prob=0.96] sample:  55%|█████▍    | 545/1000 [00:19<00:14, 30.98it/s, 63 steps of size 4.79e-02. acc. prob=0.96]sample:  55%|█████▍    | 549/1000 [00:19<00:16, 26.90it/s, 63 steps of size 4.79e-02. acc. prob=0.96]sample:  55%|█████▌    | 552/1000 [00:19<00:17, 26.07it/s, 63 steps of size 4.79e-02. acc. prob=0.96]sample:  56%|█████▌    | 555/1000 [00:19<00:19, 23.25it/s, 63 steps of size 4.79e-02. acc. prob=0.96]sample:  56%|█████▌    | 559/1000 [00:20<00:16, 26.94it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  56%|█████▋    | 564/1000 [00:20<00:13, 32.31it/s, 63 steps of size 4.79e-02. acc. prob=0.96]sample:  57%|█████▋    | 568/1000 [00:20<00:13, 31.67it/s, 63 steps of size 4.79e-02. acc. prob=0.96]sample:  57%|█████▋    | 574/1000 [00:20<00:11, 37.65it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  58%|█████▊    | 578/1000 [00:20<00:12, 34.83it/s, 127 steps of size 4.79e-02. acc. prob=0.95]sample:  58%|█████▊    | 582/1000 [00:20<00:12, 33.89it/s, 63 steps of size 4.79e-02. acc. prob=0.95] sample:  59%|█████▊    | 586/1000 [00:20<00:12, 33.21it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  59%|█████▉    | 590/1000 [00:20<00:12, 33.89it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  60%|█████▉    | 595/1000 [00:20<00:10, 36.88it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  60%|██████    | 601/1000 [00:21<00:09, 40.28it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  61%|██████    | 606/1000 [00:21<00:10, 36.40it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  61%|██████    | 610/1000 [00:21<00:10, 36.81it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  61%|██████▏   | 614/1000 [00:21<00:11, 35.00it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  62%|██████▏   | 619/1000 [00:21<00:10, 38.02it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  62%|██████▎   | 625/1000 [00:21<00:08, 41.91it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  63%|██████▎   | 630/1000 [00:21<00:08, 42.87it/s, 63 steps of size 4.79e-02. acc. prob=0.96]sample:  64%|██████▎   | 635/1000 [00:21<00:08, 43.47it/s, 63 steps of size 4.79e-02. acc. prob=0.96]sample:  64%|██████▍   | 640/1000 [00:22<00:08, 43.69it/s, 63 steps of size 4.79e-02. acc. prob=0.96]sample:  64%|██████▍   | 645/1000 [00:22<00:08, 42.34it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  65%|██████▌   | 650/1000 [00:22<00:08, 41.46it/s, 127 steps of size 4.79e-02. acc. prob=0.96]sample:  66%|██████▌   | 655/1000 [00:22<00:08, 41.67it/s, 63 steps of size 4.79e-02. acc. prob=0.96] sample:  66%|██████▌   | 660/1000 [00:22<00:09, 35.14it/s, 63 steps of size 4.79e-02. acc. prob=0.96]sample:  66%|██████▋   | 664/1000 [00:22<00:10, 31.13it/s, 63 steps of size 4.79e-02. acc. prob=0.96]sample:  67%|██████▋   | 668/1000 [00:22<00:10, 31.06it/s, 63 steps of size 4.79e-02. acc. prob=0.96]sample:  67%|██████▋   | 672/1000 [00:23<00:12, 26.29it/s, 63 steps of size 4.79e-02. acc. prob=0.96]sample:  68%|██████▊   | 676/1000 [00:23<00:11, 27.24it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  68%|██████▊   | 679/1000 [00:23<00:13, 23.50it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  68%|██████▊   | 682/1000 [00:23<00:13, 24.24it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  69%|██████▊   | 686/1000 [00:23<00:11, 27.01it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  69%|██████▉   | 690/1000 [00:23<00:10, 29.72it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  69%|██████▉   | 694/1000 [00:23<00:10, 28.00it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  70%|██████▉   | 699/1000 [00:24<00:09, 32.14it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  70%|███████   | 703/1000 [00:24<00:08, 33.67it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  71%|███████   | 707/1000 [00:24<00:08, 34.94it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  71%|███████   | 712/1000 [00:24<00:08, 34.08it/s, 255 steps of size 4.79e-02. acc. prob=0.95]sample:  72%|███████▏  | 717/1000 [00:24<00:07, 36.32it/s, 127 steps of size 4.79e-02. acc. prob=0.95]sample:  72%|███████▏  | 721/1000 [00:24<00:07, 36.05it/s, 63 steps of size 4.79e-02. acc. prob=0.95] sample:  73%|███████▎  | 726/1000 [00:24<00:07, 37.80it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  73%|███████▎  | 731/1000 [00:24<00:06, 39.88it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  74%|███████▎  | 736/1000 [00:25<00:06, 39.14it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  74%|███████▍  | 740/1000 [00:25<00:07, 36.46it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  74%|███████▍  | 744/1000 [00:25<00:07, 35.16it/s, 127 steps of size 4.79e-02. acc. prob=0.95]sample:  75%|███████▍  | 748/1000 [00:25<00:06, 36.18it/s, 63 steps of size 4.79e-02. acc. prob=0.95] sample:  75%|███████▌  | 752/1000 [00:25<00:07, 34.32it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  76%|███████▌  | 757/1000 [00:25<00:06, 38.16it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  76%|███████▌  | 761/1000 [00:25<00:07, 33.27it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  76%|███████▋  | 765/1000 [00:25<00:06, 34.89it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  77%|███████▋  | 769/1000 [00:25<00:06, 35.36it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  77%|███████▋  | 774/1000 [00:26<00:05, 38.41it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  78%|███████▊  | 779/1000 [00:26<00:05, 41.22it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  78%|███████▊  | 784/1000 [00:26<00:05, 39.70it/s, 191 steps of size 4.79e-02. acc. prob=0.95]sample:  79%|███████▉  | 789/1000 [00:26<00:05, 36.89it/s, 63 steps of size 4.79e-02. acc. prob=0.94] sample:  80%|███████▉  | 795/1000 [00:26<00:05, 40.75it/s, 63 steps of size 4.79e-02. acc. prob=0.94]sample:  80%|████████  | 800/1000 [00:26<00:05, 39.22it/s, 63 steps of size 4.79e-02. acc. prob=0.94]sample:  80%|████████  | 805/1000 [00:26<00:04, 39.95it/s, 63 steps of size 4.79e-02. acc. prob=0.94]sample:  81%|████████  | 810/1000 [00:27<00:04, 38.32it/s, 63 steps of size 4.79e-02. acc. prob=0.94]sample:  81%|████████▏ | 814/1000 [00:27<00:04, 37.75it/s, 127 steps of size 4.79e-02. acc. prob=0.94]sample:  82%|████████▏ | 818/1000 [00:27<00:05, 35.25it/s, 191 steps of size 4.79e-02. acc. prob=0.95]sample:  82%|████████▏ | 823/1000 [00:27<00:04, 37.20it/s, 127 steps of size 4.79e-02. acc. prob=0.95]sample:  83%|████████▎ | 827/1000 [00:27<00:04, 36.70it/s, 127 steps of size 4.79e-02. acc. prob=0.95]sample:  83%|████████▎ | 831/1000 [00:27<00:04, 36.44it/s, 63 steps of size 4.79e-02. acc. prob=0.95] sample:  84%|████████▎ | 836/1000 [00:27<00:04, 39.69it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  84%|████████▍ | 841/1000 [00:27<00:03, 41.28it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  85%|████████▍ | 846/1000 [00:27<00:03, 40.76it/s, 63 steps of size 4.79e-02. acc. prob=0.94]sample:  85%|████████▌ | 851/1000 [00:28<00:04, 34.37it/s, 127 steps of size 4.79e-02. acc. prob=0.94]sample:  86%|████████▌ | 855/1000 [00:28<00:04, 34.09it/s, 127 steps of size 4.79e-02. acc. prob=0.95]sample:  86%|████████▌ | 860/1000 [00:28<00:03, 36.86it/s, 63 steps of size 4.79e-02. acc. prob=0.94] sample:  86%|████████▋ | 865/1000 [00:28<00:03, 39.04it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  87%|████████▋ | 870/1000 [00:28<00:03, 41.52it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  88%|████████▊ | 875/1000 [00:28<00:02, 42.03it/s, 63 steps of size 4.79e-02. acc. prob=0.94]sample:  88%|████████▊ | 881/1000 [00:28<00:02, 42.35it/s, 127 steps of size 4.79e-02. acc. prob=0.94]sample:  89%|████████▊ | 886/1000 [00:28<00:02, 41.97it/s, 127 steps of size 4.79e-02. acc. prob=0.94]sample:  89%|████████▉ | 891/1000 [00:29<00:03, 35.85it/s, 127 steps of size 4.79e-02. acc. prob=0.94]sample:  90%|████████▉ | 895/1000 [00:29<00:02, 35.65it/s, 63 steps of size 4.79e-02. acc. prob=0.94] sample:  90%|█████████ | 900/1000 [00:29<00:02, 39.08it/s, 63 steps of size 4.79e-02. acc. prob=0.94]sample:  90%|█████████ | 905/1000 [00:29<00:02, 37.08it/s, 63 steps of size 4.79e-02. acc. prob=0.94]sample:  91%|█████████ | 909/1000 [00:29<00:02, 36.77it/s, 127 steps of size 4.79e-02. acc. prob=0.94]sample:  91%|█████████▏| 913/1000 [00:29<00:02, 36.71it/s, 127 steps of size 4.79e-02. acc. prob=0.95]sample:  92%|█████████▏| 917/1000 [00:29<00:02, 36.23it/s, 63 steps of size 4.79e-02. acc. prob=0.95] sample:  92%|█████████▏| 922/1000 [00:29<00:02, 37.73it/s, 127 steps of size 4.79e-02. acc. prob=0.94]sample:  93%|█████████▎| 927/1000 [00:30<00:01, 39.04it/s, 63 steps of size 4.79e-02. acc. prob=0.94] sample:  93%|█████████▎| 932/1000 [00:30<00:01, 41.11it/s, 63 steps of size 4.79e-02. acc. prob=0.94]sample:  94%|█████████▎| 937/1000 [00:30<00:01, 41.48it/s, 63 steps of size 4.79e-02. acc. prob=0.94]sample:  94%|█████████▍| 942/1000 [00:30<00:01, 41.30it/s, 63 steps of size 4.79e-02. acc. prob=0.94]sample:  95%|█████████▍| 947/1000 [00:30<00:01, 41.80it/s, 127 steps of size 4.79e-02. acc. prob=0.95]sample:  95%|█████████▌| 953/1000 [00:30<00:01, 45.21it/s, 63 steps of size 4.79e-02. acc. prob=0.94] sample:  96%|█████████▌| 958/1000 [00:30<00:01, 41.65it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample:  96%|█████████▋| 963/1000 [00:30<00:00, 42.29it/s, 63 steps of size 4.79e-02. acc. prob=0.94]sample:  97%|█████████▋| 969/1000 [00:31<00:00, 43.26it/s, 127 steps of size 4.79e-02. acc. prob=0.95]sample:  98%|█████████▊| 975/1000 [00:31<00:00, 45.71it/s, 63 steps of size 4.79e-02. acc. prob=0.94] sample:  98%|█████████▊| 981/1000 [00:31<00:00, 47.30it/s, 63 steps of size 4.79e-02. acc. prob=0.94]sample:  99%|█████████▊| 986/1000 [00:31<00:00, 45.90it/s, 63 steps of size 4.79e-02. acc. prob=0.94]sample:  99%|█████████▉| 991/1000 [00:31<00:00, 46.32it/s, 63 steps of size 4.79e-02. acc. prob=0.95]sample: 100%|█████████▉| 996/1000 [00:31<00:00, 42.20it/s, 127 steps of size 4.79e-02. acc. prob=0.94]sample: 100%|██████████| 1000/1000 [00:31<00:00, 31.50it/s, 63 steps of size 4.79e-02. acc. prob=0.94]

Network Models

# Setup device------------------------------------------------
from BI import bi, jnp

# Setup device------------------------------------------------
m = bi(platform='cpu')
# Simulate data ------------------------------------------------
N = 50
individual_predictor = m.dist.normal(0,1, shape = (N,1), sample = True)

kinship = m.dist.bernoulli(0.3, shape = (N,N), sample = True)
kinship = kinship.at[jnp.diag_indices(N)].set(0)

def sim_network(kinship, individual_predictor):
  # Intercept
  alpha = m.dist.normal(0,1, sample = True)

  # SR
  sr = m.net.sender_receiver(individual_predictor, individual_predictor, s_mu = 0.4, r_mu = -0.4, sample = True)

  # D
  DR = m.net.dyadic_effect(kinship, d_sd=2.5, sample = True)

  return m.dist.bernoulli(logits = alpha + sr + DR, sample = True)


network = sim_network(m.net.mat_to_edgl(kinship), individual_predictor)

# Predictive model ------------------------------------------------

m.data_on_model = dict(
    network = network, 
    dyadic_predictors = m.net.mat_to_edgl(kinship),
    focal_individual_predictors = individual_predictor,
    target_individual_predictors = individual_predictor
)


def model(network, dyadic_predictors, focal_individual_predictors, target_individual_predictors):
    N_id = network.shape[0]

    # Block ---------------------------------------
    alpha = m.dist.normal(0,1, sample = True)

    ## SR shape =  N individuals---------------------------------------
    sr =  m.net.sender_receiver(
      focal_individual_predictors,
      target_individual_predictors,
      s_mu = 0.4, r_mu = -0.4
    )

    # Dyadic shape = N dyads--------------------------------------  
    dr = m.net.dyadic_effect(dyadic_predictors, d_sd=2.5) # Diadic effect intercept only 

    m.dist.bernoulli(logits = alpha + sr + dr, obs=network)

m.fit(model, num_samples = 500, num_warmup = 500, num_chains = 1, thinning = 1)